#ifndef __TREE_H
#define __TREE_H

#include "t3types.h"

/*Constantes*/

#define ENDIDX 4294967295
#define MAXPALAVRAS 100000
#define MAXNLISTA 500000
#define BUFFERCHAR 4*1048576

/*Flags*/

#define _FWORD 1		//palavra do arquivo
#define _FPART 1<<1		//parte de uma palavra maior
#define _FGEN  1<<2		//se ja foi gerada
#define _LARGER  1<<3   //maior que 5

/*Estruturas*/

typedef struct {
	flag_t found; //se ja foi encontrada
	flag_t flag; 
	int height;
	index_t path;
	index_t left;
	index_t right;
	index_t str;
	int len;
	index_t lpart;
} avlnode;

typedef struct {
	index_t word;
	index_t next;
} listnode;

typedef struct {
	avlnode * node;
	index_t nextfree;
	int nodescount[5];
	index_t root[5];
	int strcur;
	char * str;
	int nextlistn;
	listnode * list;
} multtree;


multtree * create_multtree();
void delete_multtree(multtree * tree);
int findnode(multtree * mtree, int wsize, const char word[], index_t * idx);
index_t insertword(multtree * mtree, const char word []);
void dividelarger(multtree * mtree);

void imprimet(multtree * mtree, index_t i);

#endif
